package com.ny.service.impl;

import com.ny.dao.UserDao;
import com.ny.pojo.ClassRoom;
import com.ny.pojo.User;
import com.ny.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.List;
@Service
public class UserServiceImpl implements UserService {
//    调用谁的方法，就先创建谁的对象
//    UserDao userDao = new UserDaoImpl();
    @Autowired
    private UserDao userDao;
    @Override
    public boolean login(String user_Id, String password) throws ClassNotFoundException, SQLException {
        System.out.println("service"+user_Id);
        User user = userDao.findByUserId(user_Id);
//        password  =>  user.getPassword(),密码取出来跟传进来的密码进行对比
        if(user!= null && user.getPassword().equals(password)){
            return true ;
        }
        return false;
    }

    @Override
    public List<ClassRoom> findAllRoom() throws ClassNotFoundException, SQLException {
        return userDao.findAllClassRoom();
    }


}
